//
//  QuadrantSelectionCard.swift
//  ToDo4
//
//  Created by Jeyi Zhou on 2025/10/27.
//

import SwiftUI

struct QuadrantSelectionCard: View {
    let quadrant: Quadrant
    let isSelected: Bool
    let onTap: () -> Void
    
    private var cardColor: Color {
        switch quadrant {
        case .urgentImportant:
            return .red
        case .importantNotUrgent:
            return .orange
        case .urgentNotImportant:
            return .yellow
        case .notUrgentNotImportant:
            return .green
        }
    }
    
    var body: some View {
        Button(action: onTap) {
            VStack(spacing: 8) {
                Image(systemName: quadrantIcon)
                    .font(.title2)
                    .foregroundColor(isSelected ? .white : cardColor)
                
                Text(quadrant.displayName)
                    .font(.subheadline)
                    .fontWeight(.medium)
                    .foregroundColor(isSelected ? .white : .primary)
                    .multilineTextAlignment(.center)
            }
            .frame(maxWidth: .infinity)
            .padding(.vertical, 16)
            .padding(.horizontal, 12)
            .background(
                RoundedRectangle(cornerRadius: 12)
                    .fill(isSelected ? cardColor : cardColor.opacity(0.1))
                    .overlay(
                        RoundedRectangle(cornerRadius: 12)
                            .stroke(cardColor, lineWidth: isSelected ? 0 : 1)
                    )
            )
        }
        .buttonStyle(PlainButtonStyle())
    }
    
    private var quadrantIcon: String {
        switch quadrant {
        case .urgentImportant:
            return "exclamationmark.triangle.fill"
        case .importantNotUrgent:
            return "star.fill"
        case .urgentNotImportant:
            return "clock.fill"
        case .notUrgentNotImportant:
            return "leaf.fill"
        }
    }
}
